package com.ryan.demo.url.utils;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

import org.junit.Test;

public class EncoderDemo {
	public static String encode(String sourceString,String coding) throws UnsupportedEncodingException{
		return URLEncoder.encode(sourceString,coding);
	}
	
	@Test
	public void encodeTest(){
		try {
			System.out.println(EncoderDemo.encode("你好", "utf-8"));
			System.out.println(EncoderDemo.encode("你好", "utf-16"));
			System.out.println(EncoderDemo.encode("你好", "GBK"));
			System.out.println(EncoderDemo.encode("你好", "GB2312"));
			System.out.println(EncoderDemo.encode("你好", "GB18030"));
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
	}
}
